package com.mapreduce.writable;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class mapper extends Mapper<LongWritable, Text, Text, Flowbean> {
    private Text outK = new Text();
    private Flowbean bean = new Flowbean();
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String s = value.toString();
        String[] split = s.split("\t");
        String phone = split[1];
        String up = split[split.length-3];
        String down = split[split.length-2];
        outK.set(phone);
        bean.setUp(Long.parseLong(up));
        bean.setDown(Long.parseLong(down));
        bean.setSum();
        context.write(outK,bean);
    }
}
